/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jjsoft.celularessuc.gco.neg;

import com.jjsoft.celularessuc.gco.dao.GenericController;
import com.jjsoft.celularessuc.gco.mdl.Deuda;
import com.jjsoft.celularessuc.gco.util.configuraciones;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Johnny
 */
public class DeudaManager {

    GenericController<Deuda> controladorDeuda = new GenericController<Deuda>();

    public void registrarDeuda(Deuda deuda) {
        controladorDeuda.create(deuda);
    }

    public void editarDeuda(Deuda deuda) {
        try {
            controladorDeuda.edit(deuda);
        } catch (Exception ex) {
            Logger.getLogger(DeudaManager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public List<Deuda> listarDeudas() {
        return controladorDeuda.findWhere(new Deuda(), "idSucursal=" + configuraciones.getInstance().getSucursal().getIdsucursal());
    }

    public Deuda buscarPorcedula(String cedula) {
        try {
            return controladorDeuda.findWhere(new Deuda(), "cedula_cliente='" + cedula + "'").get(0);
        } catch (Exception ex) {
            return null;
        }
    }
}
